refactor number format using Intl.NumberFormat, add parent_element option#6
Open
yearski wants to merge 6 commits intoEdddy:masterfrom
Open
refactor number format using Intl.NumberFormat, add parent_element option#6yearski wants to merge 6 commits intoEdddy:masterfrom
yearski wants to merge 6 commits intoEdddy:masterfrom
Conversation
FIX: declare variables for script mode, bump rev
refactor number format using Intl.NumberFormat, add parent_element option
1. allow calculation when input is 0: Testing for != 0 does not ensure that ensure that input is a number. This logic would need to be implemented elsewhere. Remove this condition, ensure that division by 0 is avoided/ignored. 2. implement '=': 3. refactor calculation operation logic: Change switch from KeyboardEvent.which (deprecated) to KeyboardEvent.key (this also makes code much easier to read). Remove keypress handler for key code 37 (left arrow). This functionality doesn't seem to be working as intended (divide by 100, to allow quicker decimal entry?). Instead, I added an 'm' "milli" functionality to divide by 1000, like the existing 'k' Trigger change event after '=' TotalSoFar calculation to enable external event listeners. 4. bump version, update minified file
Author
|
1159b85: |
Use jQuery offset function instead of coded calculation. The offset was not calculated correctly when using a Bootstrap modal. Also test/change the ticket visibility using jQuery instead of state variable and css.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two motivations:
Calculate/return numbers that can be directly cast as numbers without addition text parsing. The grouping ("thousands") separator is a problem. Using javascript Intl.NumberFormat class as an option allows very fine control of number to string formatting and provides additional options for currency and other locale differences. (as a minor benefit, it also simplifies the current logic that utilizes regex replacements that are somewhat inflexible)
Append to an optional parent_element instead of only $("body"). This allows the ticket to be visible when the input with calculadora is in a modal above the main body. In this case, for me, this creates a bug whereby the alignment is off (the ticket isn't close to the input to appear "attached") but at least it's visible.
I wrote this in a way that I believe is backward-compatible with the current options:
decimalsanduseCommaAsDecimalMark. It could be further simplified to eliminate those options and only use this newnumberFormatoption.I did not create a minified map so that could be done if desired.
My previous pull-request addresses a bug-fix without any change to features or functionality; it would be unnecessary if merging this PR.
I know there haven't been commits to this project for many years. So this may just be a note of appreciation. I am submitting this to share my work in case it would be useful to you or others.
Cheers,
Greg